﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace HostpitalManage.DAO
{
    class ReceptionManagementConnection
    {
        public ReceptionManagementConnection() { 
        
        }
        static SqlConnection connect = new SqlConnection("Data Source=DKHT;Initial Catalog=HospitalManagementSystem;Persist Security Info=True;User ID=sa;Password=123456");

        public DataTable timKiemBenhNhan(String id , String name) {
            DataTable dt = new DataTable();
            SqlDataAdapter adt = new SqlDataAdapter("SELECT * FROM BenhNhan WHERE MaBenhNhan like '%" + id + "%' OR HoTen like '%" + name + "%'", connect);
            adt.Fill(dt);
            return dt;
        }

        public DataTable timKiemBenhNhanHenKham(DateTime ngayHenKham)
        {
            DataTable dt = new DataTable();
            SqlDataAdapter adt = new SqlDataAdapter("SELECT * FROM BenhNhan WHERE NgayTaiKham = '" + ngayHenKham.Date.ToString() + "'", connect);
            adt.Fill(dt);
            return dt;
        }

        public void suaBenhNhan(String name, DateTime ngaysinh, String diachi, int gioitinh, int sodienthoai, String nghenghiep) {
            SqlCommand cmd = new SqlCommand("UPDATE BenhNhan SET name = @HoTen, ngaysinh = @NgaySinh, diachi = @DiaChi, gioitinh = @GioiTinh, sodienthoai = @SoDienThoai, nghenghiep = @NgheNghiep", connect);
            connect.Open();
 
        }

        public DataTable hienThiBenhNhan()
        {
            DataTable dt = new DataTable();
            SqlDataAdapter adt = new SqlDataAdapter("SELECT * FROM BenhNhan", connect);
            adt.Fill(dt);
            return dt;
        }

        public DataTable chitietdichvubenhnhan() {
            DataTable dt = new DataTable();
            SqlDataAdapter adt = new SqlDataAdapter("",connect);
            adt.Fill(dt);
            return dt;
        }
    }
}
